class Solution {//leetcode132——分割回文串II
public:
    int minCut(string s) {
        int n=s.size();
        vector<vector<bool>> assert_dp(n,vector<bool>(n));
        for(int i=n-1;i>=0;i--){
            for(int j=i;j<n;j++){
                if(s[i]==s[j]){
                    assert_dp[i][j]=i+1<j?assert_dp[i+1][j-1]:true;
                }
            }
        }
        vector<int> dp(n,INT_MAX);
        for(int i=0;i<n;i++){
            if(assert_dp[0][i]==true) dp[i]=0;
            else{
                for(int j=1;j<=i;j++){
                    if(assert_dp[j][i]) dp[i]=min(dp[i],dp[j-1]+1);
                }
            }
        }
        return dp[n-1];
    }
};